package com.example.monit.controller;

import com.example.monit.bean.ResourceError;
import com.example.monit.bean.ResponseRust;
import com.example.monit.service.ResourceErrorService;
import com.example.monit.vo.ResourceerrorTotalVo;
import com.example.monit.vo.ResourceerrorVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("/errors")
public class ResourceErrorController {
    @Autowired
    ResourceErrorService resourceErrorService;

    /**
     * 上传资源错误信息
     *
     * @param resourceError
     * @returns
     */
    @PostMapping("/resourceerrors")
    public ResponseRust uploadError(@RequestBody List<ResourceError> resourceError) throws IOException {
        return this.resourceErrorService.uploadError(resourceError);
    }

    /**
     * 获取资源错误统计信息
     *
     * @param resourceerrorTotalVo
     * @returns
     */
    @GetMapping("/resourceerrorstatistics")
    public ResponseRust totalError(ResourceerrorTotalVo resourceerrorTotalVo) throws IOException {
        return this.resourceErrorService.totalResourceerrorstatistics(resourceerrorTotalVo);
    }

    /**
     * 获取资源错误列表
     *
     * @param resourceerrorVo
     * @returns
     */
    @GetMapping("/resourceerrors")
    public ResponseRust getErrorList(ResourceerrorVo resourceerrorVo) throws IOException {
        return this.resourceErrorService.getErrorList(resourceerrorVo);
    }

}
